require.config({
                baseUrl:"../",
               paths:{
               bsl:'bsl',
               
               }
               });
require(["bsl"],function(bsl){
        //    document.addEventListener('deviceready', onDeviceready, false);
        
        
        var downItem;
        var downItem2;
        //        var downloadManager=window.plugins.downloadManager;
        var downloadManager=bsl.download;
        downloadManager.enumerate();
        
        function createDownload(){

        var  downloader=downItem;
        downItem= downloadManager.createDownload({
                                                 url:"http://dldir1.qq.com/qqfile/qq/QQ2013/QQ2013SP5/9050/QQ2013SP5.exe",
                                                 fileName:"QQ2013SP5.exe",
                                                 path:"gg"
                                                 
                                                 },function(result){
//                                                 alert('下载结果');
                                                 })
        
        }
        
        function enumerate(){
        alert('enumerate');
        downloadManager.enumerate(function(result){
                                  for (var i=0;i<result.length;i++)
                                  {
                                  var down=result[i];
                                  for (var k=0;k<result.length;k++){
                                  
                                  }
                                  
                                  alert (down.fileID+down.fileName+"jjj");
                                  }
                                  
                                  },function(){
                                  alert("enumerate失败")
                                  });
        
        }
        function clear(){
        alert('clear');
        downloadManager.clear()
        
        }
        function startAll(){
        alert('startAll');
        downloadManager.startAll()
        
        }
        
        
        function abort(){
        alert('abort');
        downItem.abort(function(){
                       alert('暂停成功');
                       },function(){
                       alert('暂停失败');
                       },
                       [downItem]);
        
        }
        function addEventListenering(){
        downItem.addEventListenering(function(file){
                                     var m=  document.getElementById("downProgress1");
                                     m.innerHTML=file.fileName+":"+file.fileReceivedSize+"/"+file.fileSize;
                                     
                                     },function(){
                                     alert('addEventListener失败');
                                     });
        
        }
        function pause(){
        alert('pause');
        
        downItem.pause(function(){  alert('pause成功');
                       },function(){
                       alert('pause失败');
                       });
        
        }
        function resume(){
        alert('resume');
        downItem.resume();
        
        }
        function start(){
        alert('start');
        downItem.start();
        
        }
        
        function createDownload2(){
        
        
        downItem2= downloadManager.createDownload({
                                                 url:"http://dldir1.qq.com/invc/tt/QQBrowserSetup.exe",
                                                 fileName:"QQBrowserSetup.exe",
                                                 path:"kk"
                                                 
                                                 },function(result){
                                                 alert('下载结果');
                                                 })
        
        }
        function abort2(){
        alert('abort');
        downItem.abort(function(){
                       alert('暂停成功');
                       },function(){
                       alert('暂停失败');
                       },
                       [downItem]);
        
        }


        function addEventListenering2(){
        downItem2.addEventListenering(function(file){
                                     var m=  document.getElementById("downProgress2");
                                     m.innerHTML=file.fileName+":"+file.fileReceivedSize+"/"+file.fileSize;
                                     
                                     },function(){
                                     alert('addEventListener失败');
                                     });
        
        }
        function pause2(){
        alert('pause');
        
        downItem2.pause(function(){  alert('pause成功');
                       },function(){
                       alert('pause失败');
                       });
        
        }
        function resume2(){
        alert('resume');
        downItem2.resume();
        
        }
        function start2(){
        alert('start');
        downItem2.start();
        
        }

        
        
        document.getElementById("createDownload1").addEventListener("click", createDownload, false);
        document.getElementById("enumerate").addEventListener("click", enumerate, false);
        document.getElementById("clear").addEventListener("click", clear, false);
        document.getElementById("startAll").addEventListener("click", startAll, false);
        document.getElementById("abort1").addEventListener("click", abort, false);
        document.getElementById("addEventListenering1").addEventListener("click", addEventListenering, false);
        document.getElementById("pause1").addEventListener("click", pause, false);
        document.getElementById("resume1").addEventListener("click", resume, false);
        document.getElementById("start1").addEventListener("click", start, false);
        
        document.getElementById("createDownload2").addEventListener("click", createDownload2, false);
        document.getElementById("abort2").addEventListener("click", abort2, false);
        document.getElementById("addEventListenering2").addEventListener("click", addEventListenering2, false);
        document.getElementById("pause2").addEventListener("click", pause2, false);
        document.getElementById("resume2").addEventListener("click", resume2, false);
        document.getElementById("start2").addEventListener("click", start2, false);
        
        })